<template>
<div>
	<yd-cell-group>
	<yd-cell-item arrow>
        <span slot="left">开始时间：</span>
        <yd-datetime type="date" v-model="startdate" slot="right"></yd-datetime>
    </yd-cell-item>

    <yd-cell-item arrow>
        <span slot="left">结束时间：</span>
        <yd-datetime type="date" v-model="enddate" slot="right"></yd-datetime>
    </yd-cell-item>

    <yd-button size="large" type="primary" @click.native="gogo">查询</yd-button>
    
    </yd-cell-group>

	<yd-cell-group title="统计结果" >
        <yd-cell-item v-for="item in list">
            <span slot="left"><div class="hh" >{{item.tkt_name}}</div></span>
            <span slot="right">{{item.num}}</span>
        </yd-cell-item>
    </yd-cell-group>

</div>	
</template>

<script>

import { mapGetters } from 'vuex';
import { str2date, date2str } from '../../util/util'

export default {
	name: 'statistics',
	
	data () {
		return {
		  	list : [],
		  	startdate: date2str(new Date),
		  	enddate: date2str(new Date),
		}
	},

	components: {

		
	},

	computed : {
		...mapGetters([
			
		]),
	},

	methods : {
		gogo () {

			console.log(this.startdate);

			this.getList();
		},

		getList() {
			let f = 'getDeviceReceliptCountList';
			if(this.$route.query.what == '1'){
				f = 'getDeviceReceliptCountAttrList';
			}
			const para = {
				fun : f,
				device : this.$route.params.devicecode,
				start_time : this.startdate + ' 00:00:00',
				end_time : this.enddate + ' 23:59:59',
				cb : res => {
					console.log(res);
					this.list = res;
				}
			};

			this.$store.dispatch('update', para);
		},
	},

	watch:{
	    
	},

	mounted () {
		
		this.getList();
	},

}
</script>

<style scoped>

</style>
